package com.medical.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.medical.constant.MessageConstant;
import com.medical.entity.PageResult;
import com.medical.entity.QueryPageBean;
import com.medical.entity.Result;
import com.medical.pojo.CheckItem;
import com.medical.service.CheckItemService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/checkitem")
public class CheckItemController {

    //从注册中心zookeeper查找服务
    @Reference
    private CheckItemService checkItemService;

    //新增检查项
    @RequestMapping("/add.do")//RequestBody将json转换为对象
    public Result add(@RequestBody CheckItem checkItem){

        try{
            checkItemService.add(checkItem);
            return new Result(true, MessageConstant.ADD_CHECKITEM_SUCCESS);
        }catch (Exception e){
            e.printStackTrace();
            //服务调用失败
            return new Result(false, MessageConstant.ADD_CHECKITEM_FAIL);
        }
    }
    @RequestMapping("/findPage.do")//RequestBody将json转换为对象
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean){
        PageResult pageResult = checkItemService.pageQuery(queryPageBean);
        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        String s = "abc";
        
        return pageResult;
    }


}
